package com.example.new4.views;

import android.util.Log;


import com.example.new4.R;
import com.example.new4.application.MyApplication;
import com.example.new4.base.BaseActivity;
import com.example.new4.database.DBHelper;
import com.example.new4.database.DBHelper2;
import com.example.new4.entity.Course;
import com.example.new4.entity.Student;
import com.example.new4.utils.SpUtils;

import java.util.List;

import jakarta.inject.Inject;

public class InfoActivity extends BaseActivity {
    @Inject
    public Student mStudent;
    @Inject
    public DBHelper mDBHelper;

    @Inject
    public Course mCourse;
    @Inject
    public DBHelper2 mDBHelper2;
    @Inject
    public SpUtils mSpUtils;
    @Override
    public int getLayoutId() {
        return R.layout.activity_info;
    }

    @Override
    public void init() {
        /*DaggerAllComponent
                .builder()
                .studentModule(new StudentModule())
                .dBModule(new DBModule(this))
                .build()
                .injectInfoActivity(this);*/

        //Student
        ((MyApplication)getApplication()).getAllComponent().injectInfoActivity(this);
        Log.d("asdf", "Info mStudent === " + mStudent.hashCode());
        List<Student> list = mDBHelper.selectAllStudent();
        int size = list.size();
        Log.d("asdf", "Info mDBHelper === " + mDBHelper.hashCode());
        mStudent = mDBHelper.selectAllStudent().get(size - 1);
        //Log.d("asdf", "Info mStudent === " + mStudent.hashCode());
        Log.d("asdf", mStudent.toString());


        //Course
        Log.d("asdf", "Info mCourse === " + mCourse.hashCode());
        List<Course> list2 = mDBHelper2.selectAllCourse();
        int size2 = list2.size();
        Log.d("asdf", "Info mDBHelper2 === " + mDBHelper2.hashCode());
        mCourse = mDBHelper2.selectAllCourse().get(size2 - 1);
        //Log.d("asdf", "Info mStudent === " + mStudent.hashCode());
        Log.d("asdf", mCourse.toString());

        //SpUtils
        // 获取并打印数据
        String value = mSpUtils.getString("key", "Default Value");
        Log.d("InfoActivity", "mSpUtils value: " + value);

    }
}
